<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class='aui-gutter-column-lg job-event-container'>
    <div class="aui-gutter-column-md">
        <h3>{{'common_events_label' | i18n}}</h3>
    </div>
    <lv-pro-table #dataTable [config]="tableConfig" [data]="tableData"></lv-pro-table>
</div>

<ng-template #statusTpl let-item>
    <ng-container [ngSwitch]="item.level">
        <i *ngSwitchCase="jobLogLevel.info.value" lv-icon="aui-icon-job-log-info"
            lv-tooltip="{{'common_alarms_info_label' | i18n}}"></i>
        <i *ngSwitchCase="jobLogLevel.warning.value" lv-icon="aui-icon-job-log-warning"
            lv-tooltip="{{'common_alarms_warning_label' | i18n}}"></i>
        <i *ngSwitchCase="jobLogLevel.error.value" lv-icon="aui-icon-job-log-error"
            lv-tooltip="{{'common_error_label' | i18n}}"></i>
        <i *ngSwitchCase="jobLogLevel.fatal.value" lv-icon="aui-icon-job-log-critical"
            lv-tooltip="{{'common_fatal_label' | i18n}}"></i>
        <i *ngSwitchDefault lv-icon="aui-icon-job-log-info" lv-tooltip="{{'common_alarms_info_label' | i18n}}"></i>
    </ng-container>
</ng-template>


<ng-template #logInfoTpl let-item>
    <ng-container *ngIf="item.logInfo">
        <span lv-overflow>
            <span
                [innerHTML]="i18n.get(item.logInfo, _isString(item.logInfoParam) ? [item.logInfoParam] : item.logInfoParam)"></span>
        </span>
    </ng-container>
    <ng-container *ngIf="item.logDetail">
        <span lv-overflow [lvContentTpl]="logDetailTpl">
            <span
                [innerHTML]="i18n.get(item.logDetail, _isString(item.logDetailParam) ? [item.logDetailParam] : item.logDetailParam, false, false, job?.sourceSubType)"></span>
        </span>
        <ng-template #logDetailTpl>
            <span
                [innerHTML]="i18n.get(item.logDetail, _isString(item.logDetailParam) ? [item.logDetailParam] : item.logDetailParam, false, false, job?.sourceSubType)"></span>
        </ng-template>
        <span class="aui-link" (click)="viewLogInfo(item)" *ngIf="item.logDetailInfo">{{'common_view_details_label' |
            i18n}}</span>
    </ng-container>
</ng-template>


<ng-template #logDetailInfoTpl>
    <div [innerHTML]="logDetailInfo" class="log-detail-container"></div>
</ng-template>

<ng-template #startTimeTpl let-item>
    <span lv-overflow>{{(item.startTime | date:'yyyy/MM/dd HH:mm:ss':extTimeZone) | nil }}</span>
</ng-template>